/**
 * Copyright &copy; 2016-2017 <a href="https://www.lczyfz.com">联创智云</a> All rights reserved.
 */
package com.lczyfz.campusinfo.modules.campusinfo.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.lczyfz.campusinfo.common.persistence.Page;
import com.lczyfz.campusinfo.common.service.CrudService;
import com.lczyfz.campusinfo.modules.campusinfo.entity.CampusinfoSchool;
import com.lczyfz.campusinfo.modules.user.utils.ServerResponse;
import com.lczyfz.campusinfo.modules.campusinfo.dao.CampusinfoSchoolDao;

/**
 * 学校管理Service
 * @author yt
 * @version 2017-10-13
 */
@Service
@Transactional(readOnly = true)
public class CampusinfoSchoolService extends CrudService<CampusinfoSchoolDao, CampusinfoSchool> {

	@Autowired
	private CampusinfoSchoolDao campusinfoSchoolDao;

	public CampusinfoSchool get(String id) {
		return super.get(id);
	}

	/**
	 * 判断重复数据
	 */
	public CampusinfoSchool getBySchoolname(String schoolname) {
		return campusinfoSchoolDao.getByName(schoolname);
	}
	
	public List<CampusinfoSchool> findList(CampusinfoSchool campusinfoSchool) {
		return super.findList(campusinfoSchool);
	}
	
	public Page<CampusinfoSchool> findPage(Page<CampusinfoSchool> page, CampusinfoSchool campusinfoSchool) {
		return super.findPage(page, campusinfoSchool);
	}
	
	@Transactional(readOnly = false)
	public void save(CampusinfoSchool campusinfoSchool) {
		super.save(campusinfoSchool);
	}
	
	@Transactional(readOnly = false)
	public void delete(CampusinfoSchool campusinfoSchool) {
		super.delete(campusinfoSchool);
	}
	
	public List<CampusinfoSchool> findAllList(CampusinfoSchool CampusinfoSchool){
		return campusinfoSchoolDao.findAllList(CampusinfoSchool);
	}
	
	public ServerResponse<List<CampusinfoSchool>> getCampusinfoSchools(){
		List<CampusinfoSchool> schoolNames = campusinfoSchoolDao.findAllList(new CampusinfoSchool());

		if(schoolNames == null){
			return ServerResponse.createByErrorMessage("获取学校失败");
		}
		return ServerResponse.createBySuccess(schoolNames);
		
	}
	
	
}